﻿namespace Com.ZGH.Dns
{
    public class DnsFlag
    {
        private int value;

        public int Get(int start, int bits)
        {
            var mask = ~(value << bits);
            return value >> (16 - bits - start) & mask;
        }

        public void Set(int start, int bits, int v)
        {
            var mask = ~(value << bits);
            v = v & mask;
            v = v << (16 - bits - start);
            value = value | v;
        }
    }
}
